import { DeleteRequest, PostRequest, PutRequest } from '@/utils/request'
import type { Response } from '@/utils/request'

export type DeviceMessageModel = {
  type: string
  snTicket: string
  sn: string
  modelId: string
}
/**
 * 保存设备消息订阅信息
 * @param haId 设备id
 * @param miniProgramType
 * @param templateId
 * @param type
 * @returns
 */
export function savePermanentInfo(
  haId: string,
  miniProgramType: string,
  templateId: any,
  type: any
): Promise<Response<string>> {
  return PutRequest('/api/WxuserHaidInfo/savePermanentInfo', {
    haId: haId,
    miniProgramType: miniProgramType,
    templateId: templateId,
    type: type,
  })
}

/**
 * 获取用户订阅消息
 * @param haId
 * @param miniProgramType
 * @returns
 */
export function getUserPermanentInfo(haId: string, miniProgramType: string): Promise<Response<DeviceMessageModel>> {
  return PostRequest('/api/WxuserHaidInfo/permanentInfo', {
    haId: haId,
    miniProgramType: miniProgramType,
  })
}

/**
 * 重置设备消息订阅信息
 */
export function resetPermanentInfo(): Promise<Response<DeviceMessageModel>> {
  return DeleteRequest('/api/WxuserHaidInfo/deletePermanentInfo')
}
